using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class SITMTYPEMap : EntityTypeConfiguration<SITMTYPE>
    {
        public SITMTYPEMap()
        {
            // Primary Key
            this.HasKey(t => new { t.UTYPEID, t.TYPEID });

            // Properties
            this.Property(t => t.TYPEID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("SITMTYPE");
            this.Property(t => t.UTYPEID).HasColumnName("UTYPEID");
            this.Property(t => t.TYPEID).HasColumnName("TYPEID");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");

            // Relationships
            this.HasRequired(t => t.ItemType)
                .WithMany(t => t.SITMTYPEs)
                .HasForeignKey(d => d.TYPEID);
            this.HasRequired(t => t.UserType)
                .WithMany(t => t.SITMTYPEs)
                .HasForeignKey(d => d.UTYPEID);

        }
    }
}
